package Thread;

//懒汉模式
class SingleLazy {
    private static volatile SingleLazy instance = null;

    private static Object locker = new Object();

    public static SingleLazy getInstance() {
        if (instance == null) {
            synchronized (locker) {
                if (instance == null) {
                    instance = new SingleLazy();
                }
            }
        }
        return instance;
    }
    private SingleLazy() {

    }
}
public class demo14 {
    public static void main(String[] args) {
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();
        System.out.println(s1 == s2);
    }
}
